package com.qut.graduate.busrtquery.greendao.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.PoiInfo;
import com.qut.graduate.busrtquery.BRTQConstant;
import com.qut.graduate.busrtquery.bean.BusInfoLineQuery;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

/**
 * 数据库站点查询历史表和收藏表的实体类
 */
@Entity
public class StationInfo implements Parcelable {
    @Id(autoincrement = true)
    private Long id;
    private String name = "";
    private String address = "";
    private String city = "青岛";
    private double latitude;
    private double longitude;
    private String time = "";

    public StationInfo(PoiInfo poiInfo) {
        this.name = poiInfo.getName();
        this.address = poiInfo.getAddress();
        this.latitude = poiInfo.getLocation().latitude;
        this.longitude = poiInfo.getLocation().longitude;
        this.city = poiInfo.getCity();
        String format = BRTQConstant.timeFormat.format(System.currentTimeMillis());
        this.time = format;
    }

    public StationInfo(StationInfoCollect stationInfoCollect) {
        this.name = stationInfoCollect.getName();
        this.address = stationInfoCollect.getAddress();
        this.latitude = stationInfoCollect.getLatitude();
        this.longitude = stationInfoCollect.getLongitude();
        this.city = stationInfoCollect.getCity();
        String format = BRTQConstant.timeFormat.format(System.currentTimeMillis());
        this.time = format;
    }

    @Override
    public String toString() {
        return "StationInfo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", city='" + city + '\'' +
                ", latitude=" + latitude +
                ", longitude=" + longitude +
                ", time='" + time + '\'' +
                '}' + '\n';
    }

    protected StationInfo(Parcel in) {
        if (in.readByte() == 0) {
            id = null;
        } else {
            id = in.readLong();
        }
        name = in.readString();
        address = in.readString();
        city = in.readString();
        latitude = in.readDouble();
        longitude = in.readDouble();
        time = in.readString();
    }

    public static final Creator<StationInfo> CREATOR = new Creator<StationInfo>() {
        @Override
        public StationInfo createFromParcel(Parcel in) {
            return new StationInfo(in);
        }

        @Override
        public StationInfo[] newArray(int size) {
            return new StationInfo[size];
        }
    };

    @Generated(hash = 433441946)
    public StationInfo(Long id, String name, String address, String city,
            double latitude, double longitude, String time) {
        this.id = id;
        this.name = name;
        this.address = address;
        this.city = city;
        this.latitude = latitude;
        this.longitude = longitude;
        this.time = time;
    }

    @Generated(hash = 1017864651)
    public StationInfo() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public double getLatitude() {
        return this.latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return this.longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getTime() {
        return this.time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getCity() {
        return this.city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        if (id == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeLong(id);
        }
        parcel.writeString(name);
        parcel.writeString(address);
        parcel.writeString(city);
        parcel.writeDouble(latitude);
        parcel.writeDouble(longitude);
        parcel.writeString(time);
    }
}
